home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
gnu
/
gawk
/
gawk213s.zoo
/
gawk-src-2.13
/
vms
/
version.com
< prev
next >
Wrap
Text File
|
1991-05-02
|
2KB
|
63 lines
$! version.com -- very crude 'sh' for processing gawk's version.sh [pr]
$!
$! Use version.sh to create version.c, substituting the current
$! version identification.
$!
$ on error then goto unhandled_error
$ on control_Y then goto error_exit
$ if p1.nes."" then goto p1_ok
$ write sys$error "you must specify a release number on the command line"
$ goto error_exit
$p1_ok:
$ key = "" !no substitution target yet
$ open/read/error=cant_open_sh f_in version.sh
$prolog_loop:
$ read/end=eof_in_prolog f_in buf
$ ! look for ``RELEASE="$1"''
$ if f$locate("$1",buf).lt.f$length(buf) then key = f$element(0,"=",buf)
$ ! look for ``cat << EOF''
$ if f$extract(0,3,buf).nes."cat" then goto prolog_loop
$ ! found ``cat''; look for "<" and assume that it's actually "<<"
$ eof_token = f$edit(f$element(2,"<",buf),"TRIM")
$ key = "${" + key + "}" !"RELEASE" -> "${RELEASE}"
$ open/write/error=cant_open_c f_out version.c
$copy_loop:
$ read/end=eof_too_soon f_in buf
$ ! check for EOF sentinel
$ if buf.eqs.eof_token then goto copy_done
$ pos = 0
$subs: ! look for substitution target
$ pos = pos + f$locate(key,f$extract(pos,999,buf))
$ if pos.eq.f$length(buf) then goto substitute_done
$ ! perform substitution
$ buf = f$extract(0,pos,buf) + p1 + f$extract(pos+f$length(key),999,buf)
$ pos = pos + f$length(p1) - f$length(key)
$ goto subs !look at the resulting line again
$substitute_done:
$ write f_out buf
$ goto copy_loop
$copy_done:
$ close f_in
$ close f_out
$ exit !success
$!
$! rudimentary error handling
$cant_open_sh:
$ write sys$error "Could not open ""version.sh"" for input"
$ goto error_exit
$cant_open_c:
$ write sys$error "Could not create ""version.c"" for output"
$ goto error_exit
$eof_in_prolog:
$ write sys$error "Never found ""cat"" command for controlling output"
$ goto error_exit
$eof_too_soon:
$ write sys$error "Never found """,eof_token,""" line for terminating output"
$ goto error_exit
$unhandled_error:
$ write sys$error "Unexpected error encountered" !this won't be much help :-(
$error_exit:
$ if f$trnlmn("f_in") .nes."" then close/nolog f_in
$ if f$trnlmn("f_out").nes."" then close/nolog f_out
$ exit %x1000002C !SS$_ABORT | STS$M_INHIB_MSG